#!/bin/bash

echo "Running post installation script."

if [ "$UID" != 0 ]; then
   echo "You must be root to run this program !"
   echo "Please re-run this script while root so that testcloud will be "
   echo "completly installed."
   exit 1
fi

vbox_v=`VBoxManage --version`
vbox_v2=`expr "$vbox_v" : "\(.....\)"`

vbox_v_major=`echo "$vbox_v2" | awk -F "." '{ print $1 }'`
vbox_v_minor=`echo "$vbox_v2" | awk -F "." '{ print $2 }'`
vbox_v_tiny=`echo "$vbox_v2" | awk -F "." '{ print $3 }'`

if [ ${vbox_v_major} -lt 2 ]
then
   echo "VirtualBox version 2.2 or higher is required"
   exit 2
fi

if [ ${vbox_v_minor} -lt 2 ]
then
   echo "VirtualBox version 2.2 or higher is required"
   exit 2
fi

echo ""
echo "Run the script 'testcloud setup' to add virtual hard disks to Testcloud."
echo ""

exit 0
